package com.wmd.core.util;

/**
 * @projectName:DocumentLibrary
 * @packageName:com.wmd.core.util
 * @Description:TODO
 * @Author:luyincheng
 * @CreateDate: 2023/10/1013:20
 */
public class EnumUtils {
    public static <T extends Enum<T>> T getEnum(Class<T> enumType,String name){
        try{
            T enumdata=Enum.valueOf(enumType,name);
            return enumdata;
        }catch (IllegalArgumentException|NullPointerException e){
            return null;
        }
    }

    public static <T extends Enum<T>> String getEnumNameInEnums(Class<T> enumType,String name){
        try{
            T enumdata=Enum.valueOf(enumType,name);
            return enumdata.name();
        }catch (IllegalArgumentException|NullPointerException e){
            return null;
        }
    }

    public static <T extends Enum<T>> String getEnumNameNotInEnums(Class<T> enumType,String name){
        try{
            T enumdata=Enum.valueOf(enumType,name);
            return null;
        }catch (IllegalArgumentException|NullPointerException e){
            return name;
        }
    }
}
